
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix='fn' uri="http://java.sun.com/jsp/jstl/functions"%>


<%@ include file="../cabecalho.jsp"%>

<link href="<c:url value='/'/>/css/jquery-ui.css" rel="stylesheet"
	type="text/css" />
<script type="text/javascript" src="<c:url value='/'/>/js/gdl.js"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value='/'/>/js/interface.js"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value='/'/>/js/jquery-ui.js"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value='/'/>/js/dateFormat.js"></script>

<script type="text/javascript">
	jQuery(function($) {
		$("input.data").mask("99/99/9999", {
			placeholder : ""
		});
	});
	jQuery(function($) {
		$("#ano").mask("9999", {
			placeholder : ""
		});
	});

	$(function() {
		$(".column").sortable({
			connectWith : '.column',
			handle : $(".portlet-header")
		});

		$(".portlet").addClass(
				"ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
				.find(".portlet-header").addClass(
						"ui-widget-header ui-corner-all").prepend(
						'<span class="ui-icon ui-icon-minusthick"></span>')
				.end().find(".portlet-content");

		$(".portlet-header .ui-icon").click(
				function() {
					$(this).toggleClass("ui-icon-minusthick").toggleClass(
							"ui-icon-plusthick");
					$(this).parents(".portlet:first").find(".tabelaDiv")
							.toggle();
				});

		/*$(".column").disableSelection();*/
		$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
		$("#calendario").datepicker({
			maxDate : '+1m',
			onSelect : exibeAtividades
		});
	});

	function exibeAtividades(data) {

	}

	$.ajaxSetup({
		cache : false
	});
</script>

<script type="text/javascript">
	jQuery(function($) {
		$("#dados_view_link").live('click', function() {
		   	var spanHashUsuario = $(this).parent().find(">:first-child");							
			$.ajax(
			{					
				beforeSend: function(){
					$('#dados').html("");
					$('#fundo').show();
					$('.carregando').show();
					$('#dados').show();
	            },
				url: 'dadosPessoaisView/' + spanHashUsuario.html() ,
				success: function(data) {
				   	$('#dados').html(data);
				   	$('.carregando').hide();
				},
				error: function(txt){
		        	$('.carregando').html(txt);
				}
			});
		});
		$("#curriculo_view_link").live('click', function() {
			   	var spanHashUsuario = $(this).parent().find(">:first-child");							
				$.ajax(
				{					
					beforeSend: function(){
						$('#curriculo').html("");
						$('#fundo').show();
						$('.carregando').show();
						$('#curriculo').show();
		            },
					url: 'curriculoView/' + spanHashUsuario.html() ,
					success: function(data) {
					   	$('#curriculo').html(data);
					   	$('.carregando').hide();
					},
					error: function(txt){
			        	$('.carregando').html(txt);
					}
				});
		});
		$('.fechar_modal').live('click', function(){
			$('#curriculo').hide();
			$('#inscricao').hide();
			$('#dados').hide();
			$('#cartasDeRecomendacao').hide();
			$('#fundo').hide();
		});
		
		$("#inscricao_view_link").live('click', function() {
		   	var spanHashUsuario = $(this).parent().find(">:first-child");
			$.ajax(
			{					
				beforeSend: function(){
					$('#inscricao').html("");
					$('#fundo').show();
					$('.carregando').show();
					$('#inscricao').show();
	            },
				url: 'inscricaoView/' + spanHashUsuario.html() ,
				success: function(data) {
				   	$('#inscricao').html(data);
				   	$('.carregando').hide();
				},
				error: function(txt){
		        	$('.carregando').html(txt);
				}
			});
		});
		
		$("#cartas_recomendacao_view_link").live('click', function() {
			var spanHashUsuario = $(this).parent().find(">:first-child");
			$.ajax(
					{					
						beforeSend: function(){
							$('#cartasDeRecomendacao').html("");
							$('#fundo').show();
							$('.carregando').show();
							$('#cartasDeRecomendacao').show();
			            },
						url: 'cartasRecomendacaoView/' + spanHashUsuario.html() ,
						success: function(data) {
						   	$('#cartasDeRecomendacao').html(data);
						   	$('.carregando').hide();
						},
						error: function(txt){
				        	$('.carregando').html(txt);
						}
					});
		});
	});
	
</script>
<div>
	<form action=<c:url value='/candidato/lista'/> method="post">
		<select name="processoSeletivoId">
			<option value=""><fmt:message key="lista_candidatos_select_processo_seletivos"/></option>
			<c:forEach var="processo" items="${processosSeletivos}"
			varStatus="rowCounter">
				<option value=${processo.processoSeletivoId}><fmt:message key="${processo.tipoProcessoSeletivo.msgKey }"/> -
				 <fmt:formatDate value='${processo.dataDeAbertura}' type='date'/> -> <fmt:formatDate value='${processo.dataLimiteDeInscricao}' type='date'/></option>
			</c:forEach>
		</select>
		<input type=submit value="<fmt:message key="lista_candidatos_procurar"/>">
	</form>
</div>


<div class="column" style="width: 100%">
		<div class=tabela>
			<fmt:message key="lista_candidatos_inscricoes_cadastradas">
				<fmt:param value="${fn:length(listaDeInscricoes)}" />
			</fmt:message>
		</div>
		<div>	
		<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Professor"}'>
		<form method="post" action="salvaInteresse">
		<input type="hidden" name="idProfessor" value='${usuarioSessao.usuario.usuarioID}'/>
		</c:if>
			<table class="tabela">
				<tr>
					<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Coordenador"}'>
					<th width="10px"><b><fmt:message key="visualizacao_candidato_aprovado" /></b></th>
					</c:if>
					<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Professor"}'>
					<th width="10px"><b><fmt:message key="visualizacao_candidato_interesse" /></b></th>
					</c:if>
					<th><b><fmt:message key="visualizacao_candidato_tabela_titulo_nome" /></b></th>
					<th></th>
					<th></th>
					<th></th>
					<th></th>
					<th><fmt:message key="visualizacao_candidato_tabela_titulo_finalizada"/></th>
				</tr>
				<c:forEach  var="inscricao" items="${listaDeInscricoes}" varStatus="rowCounter">
					<c:choose>
						<c:when test="${rowCounter.count % 2 == 0}">
							<c:set var="rowStyle" scope="page" value="odd" />
						</c:when>
						<c:otherwise>
							<c:set var="rowStyle" scope="page" value="even" />
						</c:otherwise>
					</c:choose>
					<tr class="${rowStyle}">
						<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Coordenador"}'>
						<td align="center"><input type="checkbox" disabled <c:if test='${inscricao.aprovado == true}'>checked</c:if>></td>
						</c:if>
						<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Professor"}'>
						<td align="center"><input type="checkbox" name="interesse" value="${inscricao.inscricaoID}" <c:if test='${inscricoesComInteresse.contains(inscricao.inscricaoID) == true}'>checked</c:if>></td>
						<input type="hidden" name="completa" value="${inscricao.inscricaoID}"/>
						</c:if>
					    <td>${inscricao.candidato.dadosPessoais.nomeCompleto}</td>
					    <td> <span style="display: none">${inscricao.candidato.hash}</span> <a id="dados_view_link" class="handCursor"  > 
							<fmt:message key="visualizacao_candidato_tabela_dados_link"/>  </a>  
						</td>
						<td> <span style="display: none">${inscricao.candidato.hash}</span> <a id="curriculo_view_link" class="handCursor"  > 
							<fmt:message key="visualizacao_candidato_tabela_curriculo_link"/>  </a>  
						</td>
						<td> <span style="display: none">${inscricao.candidato.hash}</span> <a id="inscricao_view_link" class="handCursor" > 
							<fmt:message key="visualizacao_candidato_tabela_inscricao_link"/>  </a>  
						</td>
						<td> <span style="display: none">${inscricao.candidato.hash}</span> <a id="cartas_recomendacao_view_link" class="handCursor" > 
							<fmt:message key="visualizacao_candidato_tabela_carta_recomendacao_link"/>  </a>  
						</td>
						<td><c:if test="${inscricao.inscricaoFinalizada }">
							<fmt:message key="sim"/>
							</c:if>
							<c:if test="${not inscricao.inscricaoFinalizada }">
							<fmt:message key="nao"/>
							</c:if>
						</td>
					</tr>
				</c:forEach>
			</table>
			<c:if test='${usuarioSessao.usuario.perfil.descricao ==	"Professor"}'>
				<c:if test="${listaDeInscricoes != NULL }">
				<input type="submit" value="<fmt:message key="enviar"/>">
				</c:if>
				</form>
			</c:if>
		</div>
</div>

<div class="clear"></div>

<div class="carregando modal">
	<fmt:message key="visualizacao_candidato_msg_aguarde"/>
</div>
<div id="dados" class="modal" >
	<!-- dadosView.jsp sera carregado aqui -->
</div>
<div id="curriculo" class="modal" >
	<!-- curriculoView.jsp sera carregado aqui -->
</div>
<div id="inscricao" class="modal" >
	<!-- inscricaoView.jsp sera carregado aqui -->
</div>
<div id="cartasDeRecomendacao" class="modal" >
	<!-- cartasRecomendacaoView.jsp sera carregado aqui -->
</div>

	   
<%@ include file="../rodape.jsp"%>

<div id="fundo">
</div>